package com.jed.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jed.R;
import com.jed.entity.JiCai;

import java.util.List;

/**
 * 项目名：XMKAPP<br/>
 * 包名：  com.jed.adapter<br/>
 * 作者：徐晓辉<br/>
 * 创建日期：2018/11/28 11:10<br/>
 * 描述：集采Adapter<br/>
 */
public class JiCaiAdapter extends MyBaseAdapter {

    private JiCai jiCai;
    private List<JiCai> list;



    public JiCaiAdapter(List<JiCai> list) {
        super(list);
        this.list = list;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        Holder holder;
        if (v == null) {
            holder = new Holder();
            v = inflater.inflate(R.layout.jicai_list_item,null);
            holder.tv_xmmingcheng = v.findViewById(R.id.tv_xmmingcheng);
            holder.tv_zhubanchushi = v.findViewById(R.id.tv_zhubanchushi);
            holder.tv_yusuanjine = v.findViewById(R.id.tv_yusuanjine);
            v.setTag(holder);
        } else {
            holder = (Holder) v.getTag();
        }
        jiCai = list.get(position);
        String shenhezhuangtai = jiCai.getShenhezhuangtai();
        if (JiCai.PASS.equals(shenhezhuangtai)){
            v.setBackgroundResource(R.color.loginBut);
        }else if (JiCai.BACK.equals(shenhezhuangtai)){
            v.setBackgroundResource(R.color.colorAccent);
        }else{
            v.setBackgroundResource(R.color.white);
        }
        holder.tv_xmmingcheng.setText(jiCai.getXmmingcheng());
        holder.tv_zhubanchushi.setText(jiCai.getZhubanchushi());
        holder.tv_yusuanjine.setText(jiCai.getYusuanjine().toString());
        return v;
    }

    class Holder {
        private TextView tv_xmmingcheng;
        private TextView tv_zhubanchushi;
        private TextView tv_yusuanjine;
    }
}
